﻿using System;
using System.Collections.Generic;
using System.Web;
using System.Web.UI;

namespace NhanAi.Admin
{
    public class BasePage : System.Web.UI.Page
    {
       
        protected void SetMessage(string msg, string msgClass)
        {
            Session["message"] = msg;
            Session["message_type"] = msgClass;
            Session["message_count_get"] = 2;
        }
        protected void KeepMessage(string msg, string msgClass)
        {
            SetMessage(msg, msgClass);
            Session["message_count_get"] = 4;
        }
        protected void SetCurrentPage(string page)
        {
            Session["current_page"] = page;
        }
        public NhanAi.Entity.User CurrentUser
        {
            get
            {
                if (Session["user"] != null) return Session["user"] as NhanAi.Entity.User;
                else return null;
            }
        }
        public void Redirect(string url)
        {
            Response.Redirect(url);
        }
        protected void SetCurrentUser(NhanAi.Entity.User u)
        {
            Session["user"] = u;
        }
        protected void Authenticate()
        {
            if (CurrentUser == null) Redirect("/Public/Login.aspx");
        }
        protected void SignOut(){
            Session["user"] = null;
        }
    }
}